package com.sherry.service.impl;

import com.sherry.dao.IOrderDao;
import com.sherry.dao.impl.OrderDaoImpl;
import com.sherry.model.Order;
import com.sherry.service.IOrderService;

import java.util.List;

public class OrderServiceImpl implements IOrderService {
    private  int pageSize=3;
    private IOrderDao orderDao= new OrderDaoImpl();
    @Override
    public List<Order> getOrderList(String orderNo, int pageIndex) {
        int offSize=(pageIndex-1)*pageSize;
        return orderDao.getOrderList(orderNo,offSize,pageSize);
    }

    @Override
    public Integer getTotalPage(String orderNo) {
        Integer count=orderDao.getOrderCount(orderNo);
//        不能除尽（还有余）——》要多加一页
        Integer totalPage=count%pageSize==0?(count/pageSize):(count/pageSize)+1;
        return totalPage;
    }

    @Override
    public Integer delOrderByNo(String orderNo) {
        return orderDao.delOrderByNo(orderNo);
    }

    @Override
    public Integer updateOrder(Order order) {
        return orderDao.updateOrder(order);
    }
}
